package com.pan.crawler.impl8;

import com.pan.crawler.Search;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.edge.EdgeDriver;

import java.time.Duration;

public class SearchImpl8 implements Search {

    private final String webUrl = "m.wu62.org";

    private EdgeDriver edgeDriver;

    public SearchImpl8() {
        edgeDriver = new EdgeDriver();
        edgeDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
    }
    @Override
    public void find(String content) {
        String searchContent = content+  " site:"+webUrl;
        edgeDriver.navigate().to("https://cn.bing.com/search?q=site:m.wu62.org");
        WebElement searchBox = edgeDriver.findElement(By.className("b_searchbox"));
        searchBox.clear();
        searchBox.sendKeys(searchContent);
        searchBox.submit();
    }

    @Override
    public void close() {
        edgeDriver.quit();
    }

    public static void main(String[] args) {
        SearchImpl8 searchImpl7 = new SearchImpl8();
        searchImpl7.find("火影");
    }
}
